<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
		<link rel="stylesheet" type="text/css" href="../../css/style.css" />
		<link rel="stylesheet" type="text/css" href="../../css/demo.css" />
		<script src="../../js/demo.js" type="text/javascript" charset="utf-8"></script>
		<title>搜索店铺</title>
	</head>
	<body>
		<!--header-->
		<div class="header">
			<div class="header-content">
				<ul class="nav left">
					<li><img src="../../img/regist-arrow.png" /></li>
					<li class="nav-one">
						<a href="javascript:history.go(-1);">返回</a>
					</li>
					<li class="nav-two">
						<a href="../../">关闭</a>
					</li>
				</ul>
				<p class="left">搜索店铺</p>
				<div class="right nav_right">
					<img src="../../img/regist-list.png" />
				</div>
			</div>
		</div>
		<!--main-->
		<div class="main clear" style="margin-bottom: 1rem;">
			<div class="index-search">
				<div class="index-searchlist">
					<img src="../../img/index-icon9.png" class="left" />
					<div class="index-search-M left">
							<label for="search">
								店铺
								<img src="../../img/shopmanagement-icon8.png" alt="" />
							    <img src="../../img/shopmanagement-icon13.png"/>
							</label>
							<input type="text" name="search" id="productadd-search" value="" placeholder="输入关键词" />
							<img src="../../img/shopmanagement-icon9.png" onclick="searchShop()" />
					</div>
					<a href="../../html/shopcar/shopcar-purchase.html"><img src="../../img/index-icon8.png" class="right" /></a>
				</div>
			</div>
		</div>	
		<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
		<script type="text/javascript">
				//通过location的search属性获取url中的      ?+请求参数  
				var dataStr1 = location.search.substr(1);
				
		        var dataStr2=decodeURI(dataStr1);
		        $("input[name='search']").val(dataStr2);
				//使用decodeURI进行解码
				show_product_search(dataStr2);
				function show_product_search(dataStr){
					$.ajax({
						type:"post",
						url:"/qiaomengapp/shop/product-search",
						dataType:"json",
						data:"shopName="+dataStr,
						success:function(data){
							//清除上一次显示的内容
							$('.productsearch').remove();
							
							for ( var i in data) {
								$(".main").append("<div class='productsearch'>"+
										"<div class='productsearchlist'>"+
										"<div class='productsearch-home-imgs left'>"+
											"<img src='"+data[i].shopTitleurl+"' class=''/>"+
										"</div>"+
										"<ul class='productsearch-home left'>"+
											"<li class='search-one'>"+data[i].shopName+"</li>"+
											"<li class='search-two'>"+
												"<img src='../../img/shopcouple-icon7.png'/>"+
											"</li>"+
											"<li class='search-thr'>销量<span>"+data[i].sumSaleCount+"</span>   共"+(data[i].goodNum)+"件宝贝</li>"+
										"</ul>"+
										"<div class='productsearch-home-img right' style='margin-bottom: 0.38rem;'>"+
											"<img src='../../img/enter.png' onclick='enterShop()' shopId='"+data[i].id+"' class=''/>"+
										"</div>"+
										"<ul class='clear productimg'>"+
											"<li>"+
												"<img src='../../imgs/product-icon8.jpg'/>"+
												"<div class='' style='position: relative;top: -0.3rem;left: 0.86rem;'>"+
													"<img src='../../img/product-icon9.png' style='width: 0.92rem;height: 0.28rem;'/>"+
													"<span style='color: #fff;font-size: 0.2rem;position: absolute;left: 0.25rem;'>￥56</span>"+
												"</div>"+
											"</li>"+
											"<li>"+
											"<img src='../../imgs/product-icon8.jpg'/>"+
											"<div class='' style='position: relative;top: -0.3rem;left: 0.86rem;'>"+
												"<img src='../../img/product-icon9.png' style='width: 0.92rem;height: 0.28rem;'/>"+
												"<span style='color: #fff;font-size: 0.2rem;position: absolute;left: 0.25rem;'>￥56</span>"+
											"</div>"+
										"</li>"+
										"</ul>"+
									"</div>"+
								"</div>");

								for ( var j=0;j<data[i].shopLevel;j++) {
									$(".main>.productsearch:eq("+i+")").find(".search-two").append("<img src='../../img/shopdor-icon2.png'/>");
								}
							}
						}
					});
					
				}
				
				//点击搜索商铺
				function searchShop(){
					var $img = $(event.target);
					//得到输入的商铺名
					var $input = $img.siblings();
					var shopName = $input.val();
					location="../../html/product/product-search.html?"+shopName;
				}
				
				//进入商铺
				function enterShop(){
					var $img = $(event.target);
					var shopId = $img.attr("shopId");
					location="../../html/shopdor/shoppreview.html?"+shopId;
				}
				
		</script>
	</body>
</html>